/**
 * 问答列表
 */

import request from "./request";

/**
 * 分页获取数据
 */

export function getIssueByPage(params) {
  return request({
    url: "/api/issue",
    method: "GET",
    params: {
      ...params,
    },
  });
}

/**
 * 获得用户排名前十
 */
export function getUserByPointsRank() {
  return request({
    url: "/api/user/pointsrank",
    method: "GET",
  });
}
/**
 * 提交问题
 */
export function addIssue(newIssue) {
  return request({
    url: "/api/issue",
    method: "post",
    data: newIssue,
  });
}

/**
 * 根据用户id获得详细问题
 */
export function getIssueById(issueId) {
  return request({
    url: `/api/issue/${issueId}`,
    method: "get",
  });
}

/**
 * 更新问答
 */
export function updateIssue(issueId, newIssueInfo) {
  return request({
    url: `/api/issue/${issueId}`,
    method: "PATCH",
    data: newIssueInfo,
  });
}
